package com.onpositive.wikidataeditor;

import org.eclipse.swt.widgets.Composite;

import com.onpositive.semantic.model.api.changes.IValueListener;
import com.onpositive.semantic.model.api.changes.ObjectChangeManager;

public class FileListView extends XMLViewWithRecourses {

	public static final String ID = "com.onpositive.wikidataeditor.fileListView";

	public FileListView() {
		super("dlf/files.dlf");
		setSelectionProvider("fileList");
	}

	public void setFocus() {
	}

	// @Override
	// public void createPartControl(Composite parent) {
	// super.createPartControl(parent);
	// getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(new
	// ISelectionListener() {
	//
	//
	// @Override
	// public void selectionChanged(IWorkbenchPart part,
	// ISelection selection) {
	// if (selection instanceof org.eclipse.jface.viewers.IStructuredSelection){
	// IStructuredSelection sl=(IStructuredSelection) selection;
	// getBinding("FileList").setValue(sl.getFirstElement(), null);
	// }
	// }
	// });
	// }

	// public ArrayList<?> getDocuments(){
	// return Resources.getWorkingCategory().getDocumentsList() ;
	// }

	@Override
	public void createPartControl(Composite parent) {
		super.createPartControl(parent);
		getSelectionProvider();
		ObjectChangeManager.addWeakListener(Resources.getInstance(),
				new IValueListener<Object>() {

					@Override
					public void valueChanged(Object oldValue, Object newValue) {
						getBinding("Documents").refresh();
					}
		});
	}
}